<template>
  <div class="app-container">
    <el-radio-group v-model="tabStatus" style="margin-bottom: 20px" @change="handleStatusChange">
      <el-radio-button label="0">待回复</el-radio-button>
      <el-radio-button label="2">已忽略</el-radio-button>
      <el-radio-button label="1">已回复</el-radio-button>
    </el-radio-group>
    <el-table v-loading="loading" :data="feedbackList">
      <el-table-column label="单号" align="center" prop="quesId" />
      <el-table-column label="学号/工号" align="center" prop="quesUserNumber" />
      <el-table-column label="姓名" align="center" prop="quesUserName" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="标题" align="center" prop="quesTitle" />
      <el-table-column label="描述" align="center" prop="quesDescribe" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-document" @click="handleOpenDetails(scope.row)" v-hasPermi="['system:feedback:edit']"
            >查看详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

    <reply-table ref="reply" :currentRow="currentRow" @ok="handleQuery" />
  </div>
</template>

<script>
import { listFeedback } from '@/api/problem/feedback'
import replyTable from './replyTable'
export default {
  name: 'Feedback',
  components: { replyTable },
  data() {
    return {
      // 状态
      tabStatus: '0',
      // 遮罩层
      loading: true,
      // 选中行id
      currentRow: {},
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 问题反馈表格数据
      feedbackList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        quesStatus: '0',
      },
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleStatusChange(val) {
      this.queryParams.quesStatus = val
      this.getList()
    },
    /** 查询问题反馈列表 */
    getList() {
      this.loading = true
      listFeedback(this.queryParams)
        .then((response) => {
          this.feedbackList = response.rows
          this.total = response.total
        })
        .finally(() => {
          this.loading = false
        })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 查看详情操作 */
    handleOpenDetails(row) {
      this.currentRow = row
      this.$nextTick(function () {
        this.$refs.reply.show()
      })
    },
  },
}
</script>
